//
//  LGAppointWeekdayCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/20.
//

#import "LGAppointWeekdayCell.h"

@interface LGAppointWeekdayCell()

/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *weekday;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UIView *pointView;


@end

@implementation LGAppointWeekdayCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.weekday.text = LGNSString(dataDic[@"week_name"]);
    self.dateLabel.text = [dataDic[@"date"] substringFromIndex:5];
    self.pointView.hidden = ([dataDic[@"is_overdue"] integerValue]==0)?YES:NO;
}

-(void)setIsSelect:(BOOL)isSelect{
    _isSelect = isSelect;
    if(isSelect == YES){
        self.baseView.hidden = NO;
        self.weekday.font = LGFontWeight(14, UIFontWeightMedium);
        self.dateLabel.font = LGFontWeight(13, UIFontWeightMedium);
        self.weekday.textColor = [UIColor colorWithString:@"#3291FF"];
        self.dateLabel.textColor = [UIColor colorWithString:@"#3291FF"];
        
    }else{
        self.baseView.hidden = YES;
        self.weekday.font = LGFont(14);
        self.dateLabel.font = LGFont(13);
        self.weekday.textColor = [UIColor colorWithString:@"#333333"];
        self.dateLabel.textColor = [UIColor colorWithString:@"#333333"];
    }
}


-(void)createSubView{
    [self.contentView addSubview:self.baseView];
    [self.contentView addSubview:self.weekday];
    [self.contentView addSubview:self.dateLabel];
    [self.contentView addSubview:self.pointView];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.centerY.equalTo(self.contentView);
        make.width.equalTo(@(viewPix(50)));
        make.height.equalTo(@(viewPix(55)));
    }];
    [self.weekday mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.baseView).offset(viewPix(7));
        make.centerX.equalTo(self.baseView);
    }];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.weekday.mas_bottom).offset(viewPix(3));
        make.centerX.equalTo(self.baseView);
    }];
    [self.pointView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.dateLabel.mas_bottom).offset(viewPix(5));
        make.centerX.equalTo(self.baseView);
        make.width.height.equalTo(@(viewPix(4)));
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc]init];
        _baseView.backgroundColor = [UIColor colorWithString:@"#DFEEFF"];
        _baseView.cornerRidus = 3;
        _baseView.hidden = YES;
    }
    return _baseView;
}

-(UILabel *)weekday{
    if(!_weekday){
        _weekday = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(14) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _weekday;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(13) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _dateLabel;
}

-(UIView *)pointView{
    if(!_pointView){
        _pointView = [[UIView alloc]init];
        _pointView.backgroundColor = [UIColor colorWithString:@"#F84D4D"];
        _pointView.cornerRidus = viewPix(2);
    }
    return _pointView;
}

@end
